﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class GUITextOrderer : MonoBehaviour 
{
    public List<GUIText> texts = new List<GUIText>();
    public List<Vector3> poss;
    public bool UseCurrentPos;

	void Awake () 
    {        
         Sort();
	}

    void Sort()
    {
        if (!UseCurrentPos)
        {
            for (int i = 0; i < texts.Count; i++)
            {
                float y = ((texts.Count) - i) * (1 / ((float)texts.Count + 1));
                texts[i].transform.position = new Vector3(0.5f, y, 0.0f);
            }
        }

        else
        {
            for (int i = 0; i < texts.Count; i++)
            {
                poss.Add(texts[i].transform.position);
            }
        }
    }

    public Vector3 GetTextFinalPos(int i)
    {
        if (!UseCurrentPos)
            return new Vector3(0.5f, ((texts.Count) - i) * (1 / ((float)texts.Count + 1)), 0.0f);
        else
            return poss[i];
    }
}
